#ifndef _H_ZPIPE
#define _H_ZPIPE

#include "pipe.h"
#include <zlib.h>

enum zPStatus{
    zPE_VERSION_ERROR = Z_VERSION_ERROR,
    zPE_BUF_ERROR = Z_BUF_ERROR,
    zPE_MEM_ERROR = Z_MEM_ERROR,
    zPE_DATA_ERROR = Z_DATA_ERROR,
    zPE_STREAM_ERROR = Z_STREAM_ERROR,
    zPE_ERRNO = Z_ERRNO,
    zPE_OK = Z_OK,
    zPE_STREAM_END = Z_STREAM_END,
    zPE_NEED_DICT = Z_NEED_DICT
};

class zPipe: public pipe{

    protected:
        z_stream zstrm;

        int flush;

        zPStatus status;

        void setStatus(int);

    public:
        zPipe();
        ~zPipe();

        bool isRAvail();

        zPStatus getStatus();
        bool isError();
        const char* getStatusString();

        virtual void zInit();
        virtual void zEnd();

};

class zDeflatePipe: public zPipe{

    protected:
        int level;

    public:
        zDeflatePipe(int);
        ~zDeflatePipe();

        dSStatus consumeIS();
        dSStatus seqConsumeIS();
        dSStatus operateIS(unsigned int);

        void zInit();
        void zEnd();

};

class zInflatePipe: public zPipe{

    protected:

    public:
        zInflatePipe();
        ~zInflatePipe();

        dSStatus consumeIS();
        dSStatus seqConsumeIS();
        dSStatus operateIS(unsigned int);

        void zInit();
        void zEnd();

};

#endif
